package org.wdcode.web.http;

import org.wdcode.common.constants.EncodingConstants;
import org.wdcode.core.factory.BaseFactory;

/**
 * 获得HttpClient实例工厂
 * @see org.wdcode.web.http.HttpClient
 * @author WD
 * @since JDK6
 * @version 1.0 2009-05-26
 */
public class HttpClientFactory extends BaseFactory<HttpClient> {
	// 工厂
	private final static HttpClientFactory	FACTORY;

	/**
	 * 静态初始化
	 */
	static {
		FACTORY = new HttpClientFactory();
	}

	/**
	 * 返回工厂
	 * @return 工厂
	 */
	public final static HttpClientFactory getFactory() {
		return FACTORY;
	}

	/**
	 * 实例化一个新的HttpClient实例 使用UTF-8请求
	 * @return HttpClient
	 */
	@Override
	public final HttpClient newInstance() {
		return newInstance(EncodingConstants.UTF_8);
	}

	/**
	 * 实例化一个新的HttpClient实例
	 * @param encoding 请求头的编码
	 * @return HttpClient
	 */
	public final static HttpClient newInstance(String encoding) {
		return new HttpClientImpl(encoding);
	}

	/**
	 * 私有构造
	 */
	private HttpClientFactory() {
		super();
	}
}
